﻿@{
    Layout = null;
}
@model System.Collections.IEnumerable
<!DOCTYPE html>
@Html.Partial("LoadPanelPartial")
<html>
<head>
    @if (false)
    {
        <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    @Html.DevExpress().GetStyleSheets(
                new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }

    )
    @Html.DevExpress().GetScripts(
                    new Script { ExtensionType = ExtensionType.ListBox }
    )
    <script type="text/javascript">

        $(function () {
            $("#toolMenu").smartFloat();
            ASPxClientTextBox.Cast("NSRMC").SetText($("#hidNSRMC").val());
            ASPxClientTextBox.Cast("NSRBM").SetText($('#hidNSRBM').val());
            //ASPxClientComboBox.Cast("HY_DM").SetValue($('#hidHY_DM').val());
            ASPxClientComboBox.Cast("FFinancePropNo").SetValue($('#hidFFinancePropNo').val());
            //ASPxClientComboBox.Cast("FEnterprisePropNo").SetValue($('#hidFEnterprisePropNo').val());
            //            if ($('#hidIsNoFull').val() == "Y") {
            //                ASPxClientCheckBox.Cast("IsNoFull").SetChecked(true);
            //            }
            //            else {
            //                ASPxClientCheckBox.Cast("IsNoFull").SetChecked(false);
            //            }
        });
        function atclose() {
            gvEditing.Refresh();
        
        }
        function OnBeginCallback(s, e) {
            e.customArgs["command"] = e.command;
            e.customArgs["pageIndex"] = s.pageIndex;
            e.customArgs["pageCount"] = s.pageCount;
            e.customArgs["pageRowSize"] = s.pageRowSize;
            e.customArgs["pageRowCount"] = s.pageRowCount;

            e.customArgs["NSRMC"] = $('#hidNSRMC').val();
            e.customArgs["NSRBM"] = $('#hidNSRBM').val();
            e.customArgs["HY_DM"] = $('#hidHY_DM').val();
            e.customArgs["FFinancePropNo"] = $('#hidFFinancePropNo').val();
            e.customArgs["FEnterprisePropNo"] = $('#hidFEnterprisePropNo').val();
            e.customArgs["IsNoFull"] = $('#hidIsNoFull').val();
            e.customArgs["RPT"] = $("#hrpt").val();
        }


        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnAdd":
                    {
                        //ImportDate();
                        //window.location.href = rootPath + "/Key_NSRXX/PropAdd"
                        var rpt = $("#hrpt").val();
                        $("#popContent1").attr("src", rootPath + "/Key_NSRXX/PropAdd?report="+rpt);
                        codeModalMode1.Show();
                        break;
                    }
                case "btnAddAll":
                    {
                        lpModal.Show();
                        //window.location.href = rootPath + "/Key_NSRXX/PropAdd"
                        var rpt = $("#hrpt").val();
                        $.ajax({
                            type: 'POST',
                            url: rootPath + '/Key_NSRXX/btnAddAll',
                            data: {  Report: rpt },
                            success: function (result) {
                                lpModal.Hide();
                                if (result == "ok") {
                                    alert("添加成功！");
                                    gvEditing.Refresh();
                                    ASPxClientGridView.Cast("gvEditing").UnselectAllRowsOnPage();
                                    //parent.codeOK1();
                                    //window.location.href = rootPath + '/Key_NSRXX/Index';
                                } else
                                {
                                    alert(result);
                                }
                            }
                        });
                        break;
                    }
                case "btnDelete":
                    {
                        //TaxPayerManagerALLEdit();
                        codeDelList();
                        break;
                    }

                case "btnDeleteAll":
                    {
                        if (confirm("确定删除？")) {
                            //TaxPayerManagerALLEdit();
                            lpModal.Show();
                            //window.location.href = rootPath + "/Key_NSRXX/PropAdd"
                            var rpt = $("#hrpt").val();
                            $.ajax({
                                type: 'POST',
                                url: rootPath + '/Key_NSRXX/btnDeleteAll',
                                data: { Report: rpt },
                                success: function (result) {
                                    lpModal.Hide();
                                    if (result == "ok") {
                                        alert("删除成功！");
                                        gvEditing.Refresh();
                                        ASPxClientGridView.Cast("gvEditing").UnselectAllRowsOnPage();
                                        //parent.codeOK1();
                                        //window.location.href = rootPath + '/Key_NSRXX/Index';
                                    } else {
                                        alert(result);
                                    }
                                }
                            });
                        }
                        break;
                    }
                case "btnExcel":
                    {
                        var rpt = $("#hrpt").val();
                        $("#popContent").attr("src", rootPath + "/Key_NSRXX/ImportExcel?Report="+rpt);
                        codeModalMode.Show();
                    }
            }
        }
        function codeOK() {
            codeModalMode.Hide();
            gvEditing.Refresh();
        }
        function ImportDate() {
            lpModal.Show();
            if (confirm("是否确定重新导入纳税人数据?")) {
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Key_NSRXX/ImportDate',
                    success: function (result) {
                        if (result == "e") {
                            alert("系统异常");
                            lpModal.Hide();
                        }
                        else {
                            alert("操作成功");
                            lpModal.Hide();
                            gvEditing.Refresh();
                        }
                    }
                });
            }
        }

        //查询
        function search() {
            //            var isnofull = "N";
            //            if (IsNoFull.GetChecked()) {
            //                isnofull = "Y";
            //            }
            var s = "";
            var rpt = $("#hrpt").val();
            window.location.href = rootPath + "/Key_NSRXX/Index?report=" + rpt + "&NSRMC="
                        + NSRMC.GetText() + "&NSRBM=" + NSRBM.GetText() + "&HY_DM=" + s + "&FEnterprisePropNo="
                        + FEnterprisePropNo.GetValue() + "&FFinancePropNo=" + FFinancePropNo.GetValue() + "&IsNoFull='N'";
        }

        function codeDel(codeNo) {
            if (confirm("确定删除？")) {
                //原来方法
                //                $.ajax({
                //                    type: 'POST',
                //                    url: rootPath + '/Key_NSRXX/DelNSRXX?id=1',
                //                    data: { NSRDZDAH: codeNo },
                //                    success: function (result) {
                //                        if (result == "ok") {
                //                            alert("删除成功");
                //                            gvEditing.Refresh();
                //                            // window.location.href = rootPath + "/ZSFSManage/Index";
                //                        } else if (result == "error") {
                //                            alert("删除失败");
                //                        } else {
                //                            alert("参数错误");
                //                        }
                //                    }
                //                });

                var destreport = $("#hrpt").val();
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Key_NSRXX/Del',
                    data: { NSRDZDAH: codeNo, Report: destreport },
                    success: function (result) {
                        lpModal.Hide();
                        if (result == "exists") {
                            tbPZZL_DM.SetErrorText("编码已存在");
                            tbPZZL_DM.SetIsValid(false);
                        } else if (result == "ok") {
                            alert("删除成功！");
                            gvEditing.Refresh();
                            ASPxClientGridView.Cast("gvEditing").UnselectAllRowsOnPage();
                            //parent.codeOK1();
                            //window.location.href = rootPath + '/Key_NSRXX/Index';
                        } else {
                            alert(result);
                        }
                    }
                });
            }

        }
        function codeDelList(codeNo) {
            if (confirm("确定删除？")) {
                TaxPayerManagerALLEdit1();

            }
        }
        function TaxPayerManagerALLEdit1() {
            ASPxClientGridView.Cast("gvEditing").GetPageRowValues("NSRDZDAHstr", onvalues1);
        }

        function onvalues1(values) {
            var checkNo = "";
            var PageNoList = "";
            var checkNoList = ASPxClientGridView.Cast("gvEditing").GetSelectedKeysOnPage();
            for (var i = 0; i < checkNoList.length; i++) {
                checkNo += checkNoList[i] + ",";
            }

            for (var i = 0; i < values.length; i++) {
                PageNoList += values[i] + ",";
            }
            // var strwheres = $("#strwhere").val();
            if (checkNo != "") {
                // $("#popContent").attr("src", rootPath + "/Key_NSRXX/PropALLEdit?noList=" + checkNo + "&pageNoList=" + PageNoList + "&strwhere=" + strwheres);
                // codeModalMode.Show();
                //alert(checkNo)

                //原来方法
                //                $.ajax({
                //                    type: 'POST',
                //                    url: rootPath + '/Key_NSRXX/DelNSRXX',
                //                    data: { NSRDZDAH: checkNo },
                //                    success: function (result) {
                //                        lpModal.Hide();
                //                        if (result == "exists") {
                //                            tbPZZL_DM.SetErrorText("编码已存在");
                //                            tbPZZL_DM.SetIsValid(false);
                //                        } else if (result == "ok") {
                //                            alert("删除成功！");
                //                            gvEditing.Refresh();
                //                            //window.location.href = rootPath + '/Key_NSRXX/Index';
                //                        } else if (result == "error") {
                //                            alert("保存失败");
                //                        }
                //                    }
                //                });

                var destreport = $("#hrpt").val();
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Key_NSRXX/Del',
                    data: { NSRDZDAH: checkNo, Report: destreport },
                    success: function (result) {
                        lpModal.Hide();
                        if (result == "exists") {
                            tbPZZL_DM.SetErrorText("编码已存在");
                            tbPZZL_DM.SetIsValid(false);
                        } else if (result == "ok") {
                            alert("删除成功！");
                            gvEditing.Refresh();
                            ASPxClientGridView.Cast("gvEditing").UnselectAllRowsOnPage();
                            //parent.codeOK1();
                            //window.location.href = rootPath + '/Key_NSRXX/Index';
                        } else if (result == "error") {
                            alert("删除失败");
                        }
                    }
                });
            }
            else {
                alert("未选中任何行");
            }
        }
        function codeOK() {
            codeModalMode.Hide();
            gvEditing.Refresh();
        }

        function codeOK1() {
            codeModalMode1.Hide();
            gvEditing.Refresh();
        }

        function codeCancel() {
            codeModalMode.Hide();
        }

        function codeCancel1() {
            codeModalMode1.Hide();
            gvEditing.Refresh();
        }
        //重置
        function undo() {
            ASPxClientTextBox.Cast("NSRMC").SetText("");
            ASPxClientTextBox.Cast("NSRBM").SetText("");
            //ASPxClientTextBox.Cast("HY_DM").SetValue("");
            ASPxClientTextBox.Cast("FEnterprisePropNo").SetValue("");
            ASPxClientTextBox.Cast("FFinancePropNo").SetValue("");
            // ASPxClientComboBox.Cast("IsNoFull").SetCheck(false);

        }

        function TaxPayerManagerALLEdit() {
            ASPxClientGridView.Cast("gvEditing").GetPageRowValues("NSRDZDAHstr", onvalues);
        }


        function onvalues(values) {
            var checkNo = "";
            var PageNoList = "";
            var checkNoList = ASPxClientGridView.Cast("gvEditing").GetSelectedKeysOnPage();
            for (var i = 0; i < checkNoList.length; i++) {
                checkNo += checkNoList[i] + ",";
            }

            for (var i = 0; i < values.length; i++) {
                PageNoList += values[i] + ",";
            }
            var strwheres = $("#strwhere").val();
            if (checkNo != "") {
                $("#popContent").attr("src", rootPath + "/Key_NSRXX/PropALLEdit?noList=" + checkNo + "&pageNoList=" + PageNoList + "&strwhere=" + strwheres);
                codeModalMode.Show();
            }
            else {
                alert("未选中任何行");
            }
        }

    </script>
</head>
<body>
    <div>
        @Html.DevExpress().Menu(settings =>
        {
            settings.Name = "toolBarMenu";
            settings.ItemAutoWidth = false;
            settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
            settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
            settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

            settings.Items.Add(item =>
            {
                item.Name = "btnAdd";
                item.Text = "添加";
                item.ClientEnabled = true;
                item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");

            });
            settings.Items.Add(item =>
            {
                item.Name = "btnAddAll";
                item.Text = "添加全部";
                item.ClientEnabled = true;
                item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");

            });
            settings.Items.Add(item =>
            {
                item.Name = "btnDelete";
                item.Text = "批量删除";
                item.ItemStyle.ForeColor = System.Drawing.Color.Red;
                item.ClientEnabled = true;
                item.Image.Url = Url.Content("~/Content/ControlImages/cancel.png");

            });
            settings.Items.Add(item =>
            {
                item.Name = "btnDeleteAll";
                item.Text = "删除全部";
                item.ItemStyle.ForeColor = System.Drawing.Color.Red;
                item.ClientEnabled = true;
                item.Image.Url = Url.Content("~/Content/ControlImages/cancel.png");

            });

            settings.Items.Add(item =>
            {
                item.Name = "btnExcel";
                item.Text = "excel导入";
                item.ClientEnabled = true;
                item.Image.Url = Url.Content("~/Content/ControlImages/excel.png");
            });


            settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
            settings.ItemLinkMode = ItemLinkMode.ContentBounds;
        }).GetHtml()
    </div>
    <table width="100%" class="tableForm">
        <tr>
            <td font-size="14pt" class="tdClass" align="right">@Html.DevExpress().Label(settings => { settings.Text = "纳税编码:"; }).GetHtml()
            </td>
            <td class="tdClass">
                @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "NSRBM";
                   settings.Width = System.Web.UI.WebControls.Unit.Pixel(150);
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>
            <td font-size="14pt" class="tdClass" align="right">@Html.DevExpress().Label(settings => { settings.Text = "纳税人名称:"; }).GetHtml()
            </td>
            <td class="tdClass">
                @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "NSRMC";
                   settings.Width = System.Web.UI.WebControls.Unit.Pixel(150);
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>
            <td font-size="14pt" class="tdClass" align="right">@*@Html.DevExpress().Label(settings => { settings.Text = "行业门类:"; }).GetHtml()*@
            </td>
            <td class="tdClass">
                @*  @Html.DevExpress().ComboBox(settings =>
               {
                   settings.Name = "HY_DM";
                   settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                   settings.Width = System.Web.UI.WebControls.Unit.Pixel(150);
                   settings.Properties.TextField = "HY_MC";
                   settings.Properties.ValueField = "HY_DM";
               }).BindList(ViewData["DMHYList"]).Bind(ViewData["HY_DM"]).GetHtml()*@
            </td>
            <td class="tdClass">
                @Html.DevExpress().Button(settings =>
            {
                settings.Name = "btnSearch";
                settings.Text = "查询";
                settings.ControlStyle.CssClass = "button";
                settings.Images.Image.Url = Url.Content("~/Content/ControlImages/search.png");
                settings.ClientSideEvents.Click = "search";
            }).GetHtml()
                @Html.DevExpress().Button(settings =>
            {
                settings.Name = "btnUndo";
                settings.Text = "重置";
                settings.ControlStyle.CssClass = "button";
                settings.Images.Image.Url = Url.Content("~/Content/ControlImages/undo_blue.png");
                settings.ClientSideEvents.Click = "undo";
            }).GetHtml()
            </td>
        </tr>
        <tr>
            <td font-size="14pt" class="tdClass" align="right">@Html.DevExpress().Label(settings => { settings.Text = "企业性质:"; }).GetHtml()
            </td>
            <td class="tdClass">
                @Html.DevExpress().ComboBox(settings =>
               {
                   settings.Name = "FEnterprisePropNo";
                   settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                   settings.Width = System.Web.UI.WebControls.Unit.Pixel(150);
                   settings.Properties.TextField = "FEnterprisePropName";
                   settings.Properties.ValueField = "FEnterprisePropNo";
               }).BindList(ViewData["EnterprisePropList"]).Bind(ViewData["FEnterprisePropNo"]).GetHtml()
            </td>
            <td font-size="14pt" class="tdClass" align="right">@Html.DevExpress().Label(settings => { settings.Text = "资金性质:"; }).GetHtml()
            </td>
            <td class="tdClass">
                @Html.DevExpress().ComboBox(settings =>
               {
                   settings.Name = "FFinancePropNo";
                   settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                   settings.Width = System.Web.UI.WebControls.Unit.Pixel(150);
                   settings.Properties.TextField = "FFinancePropShortName";
                   settings.Properties.ValueField = "FFinancePropNo";
               }).BindList(ViewData["FinancePropList"]).Bind(ViewData["FFinancePropNo"]).GetHtml()
            </td>
            <td font-size="14pt" class="tdClass" align="right">
            </td>
            <td class="tdClass">
                @*        @Html.DevExpress().CheckBox(settings => {
       settings.Text = "信息不完整企业";
       settings.Name = "IsNoFull";
   }).GetHtml()*@
            </td>
            <td class="tdClass">
            </td>
        </tr>
    </table>
    @Html.Partial("TaxPayerManagerListPartial", Model)
    @Html.DevExpress().PopupControl(
    settings =>
    {
        settings.Name = "codeModalMode";
        settings.Width = 600;
        settings.Height = 250;
        settings.AllowDragging = true;
        settings.CloseAction = CloseAction.CloseButton;
        settings.EnableAnimation = false;
        settings.HeaderText = "纳税户设置";
        settings.Modal = true;
        settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
        settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
        settings.ShowFooter = true;

       
        settings.SetFooterTemplateContent(s =>
        {
            ViewContext.Writer.Write("<table align='center'><tr><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnOK";
                footBtnSettings.Text = "确定";
                footBtnSettings.ClientSideEvents.Click = "function(s,e){popContent.OK()}";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnCancel";
                footBtnSettings.Text = "取消";
                footBtnSettings.ClientSideEvents.Click = "codeCancel";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td></tr></table>");

        });
        settings.SetContent(() =>
       {
           ViewContext.Writer.Write("<iframe  id='popContent' name='popContent' style='width:100%;height:200px' frameborder='0' ></iframe>");
       });
    }).GetHtml()
    @Html.DevExpress().PopupControl(
    settings =>
    {
        settings.Name = "codeModalMode1";
        settings.Width = 700;
        settings.Height = 400;
        settings.AllowDragging = true;
        settings.CloseAction = CloseAction.CloseButton;
        settings.EnableAnimation = false;
        settings.HeaderText = "添加纳税人";
        settings.Modal = true;
        settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
        settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
        settings.ShowFooter = true;
        settings.ClientSideEvents.Closing = "function(s, e) { atclose()}";
        settings.SetFooterTemplateContent(s =>
        {
            ViewContext.Writer.Write("<table align='center'><tr><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnOK1";
                footBtnSettings.Text = "保存";
                footBtnSettings.ClientSideEvents.Click = "function(s,e){popContent1.TaxPayerManagerALLEdit()}";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td><td>");
            @Html.DevExpress().Button(footBtnSettings =>
            {
                footBtnSettings.Name = "btnCancel1";
                footBtnSettings.Text = "取消";
                footBtnSettings.ClientSideEvents.Click = "codeCancel1";
                footBtnSettings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
                footBtnSettings.CausesValidation = false;
            }).GetHtml();
            ViewContext.Writer.Write("</td></tr></table>");

        });
        settings.SetContent(() =>
       {
           ViewContext.Writer.Write("<iframe  id='popContent1' name='popContent1' style='width:100%;height:400px' frameborder='0' ></iframe>");
       });
    }).GetHtml()
    @Html.Hidden("strwhere", ViewData["strwhere"])
    @Html.Hidden("hidNSRMC", ViewData["NSRMC"])
    @Html.Hidden("hidNSRBM", ViewData["NSRBM"])
    @Html.Hidden("hidHY_DM", ViewData["HY_DM"])
    @Html.Hidden("hidFFinancePropNo", ViewData["FFinancePropNo"])
    @Html.Hidden("hidFEnterprisePropNo", ViewData["FEnterprisePropNo"])
    @Html.Hidden("hidIsNoFull", ViewData["IsNoFull"])
    @Html.Hidden("hrpt", ViewData["rpt"])
    <script>
        lp.Hide();
    </script>
</body>
</html>
